<?php

namespace App\Http\Models;

use Illuminate\Database\Eloquent\Model;

class Fan extends Model
{
    // 指定表名
    protected $table = 'fans';

    // 允许批量赋值的字段
    protected $fillable = ['fan_id', 'star_id'];

    // 禁止批量赋值的字段
    protected $guarded = [];

    // 获取当前条记录关联的user(粉丝)
    public function fuser()
    {
        return $this->hasOne(User::class, 'id', 'fan_id');
    }

    // 获取当前条记录关联的user(明星)
    public function suser()
    {
        return $this->hasOne(User::class, 'id', 'star_id');
    }

    
}
